﻿@using OPM
@using OPM.MultiResource;
@model OPM.Models.GetCase

<div id="servicePage1" class="servicePage">

    <table>
        <tr>
            <td>@Multi.date_opened</td>
            <td>
                <input type="text" name="date_opened" id="date_opened" class="date-input"
                       value="@(Model.date_opened.HasValue?
                       Model.date_opened.Value.ToString("dd/MM/yyyy",new System.Globalization.CultureInfo("en-US")):"")" />
                &nbsp;&nbsp;<span class="star">*</span>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>
                <select name="hour" id="hour" class="date-time-input">
                    @for (int i = 0; i < 24; i++)
                    {
                        <option value="@i" 
                                @(Model.date_opened.HasValue && Model.date_opened.Value.Hour == i?"selected":"")>
                            @(i.ToString("00"))
                        </option>
                        i++;
                    }
                </select>
                <span class="star">*</span>
                <select name="minute" id="minute" class="date-time-input">
                    @for (int i = 0; i < 60; i++)
                    {
                        <option value="@i"
                                @(Model.date_opened.HasValue && Model.date_opened.Value.Minute == i ? "selected" : "")>
                            @(i.ToString("00"))
                        </option>
                        i++;
                    }
                </select>
                <span class="star">*</span>
            </td>
        </tr>
        <tr>
            <td>@Multi.ChanelIn</td>
            <td>
                <a href="@Url.Action("LovChannelIn", "Complaint")?a=chanel" data-block="chanel" class="formBtn3 dBlock">@Multi.select_chanel</a><span class="star">*</span>
                <span id="block_chanel"></span>
            </td>
        </tr>
        <tr>
            <td>@Multi.objective</td>
            <td>
                <a href="@Url.Action("LovContactObj", "Complaint")?a=objective" data-block="objective" class="formBtn3 dBlock" >@Multi.objectivity</a><span class="star">*</span>
                <span id="block_objective"></span>
                <input type="hidden" name="block_objective_root_value" id="block_objective_root_value" value="" />
            </td>
        </tr>
    </table>
    <div class="boxBlank"></div>
    <div>
        <div class="BoxServiceActionNext floatR" onclick="nextPage();">@Multi.NextPage</div>
        <div class="clear"></div>
    </div>
</div>

<script type="text/javascript">

    @*var objreturn = '';
    var i = 0;
    function GetRoorObj(obj) {
        console.log(obj);

        //var dataobj = $("#block_objective_root_value").val();
        var url = "@Url.Action("RootContactObj", "Complaint")?id=" + obj;

        $.getJSON(url)
			.done(function (json) {
			    console.log(json);

			    if (json != "") {
			        GetRoorObj(json)
			        objreturn = json
			        i++;
			    }

			    if (i == 0) { $('#block_objective_root_value').val(obj); }
			    else { $('#block_objective_root_value').val(objreturn); }

			});
    }

    ////ช่องทางการติดต่อ
    var chaInreturn = '';
    var i = 0;
    function GetRootChain(ChaIn, type, text) {
        console.log(ChaIn);

        var url = "@Url.Content("~/Complaint/RootChannel")?id=" + ChaIn;

        $.getJSON(url)
			.done(function (json) {
			    console.log(json);

			    if (json != "") {
			        GetRootChain(json, type, text)
			        chaInreturn = json
			        i++;
			    }

			    if (i == 0) { $('#block_chain_root_value').val(ChaIn); }
			    else { $('#block_chain_root_value').val(chaInreturn); }

			});
    }*@



    function nextPage() {

        var page1_date = $("#date_opened").val();
        var page1_block_chanel = $('#block_chanel input[type=hidden]').val();
        var val_page1_object = $('#block_objective input[type=hidden]').val();
        var hour = $("#hour").val();
        var minute = $("#minute").val();

        if (page1_date == undefined || page1_date == null) {
            alert("กรุณาป้อนวันที่ติดต่อ");
            nextStep(1);
        } else if (page1_block_chanel == undefined || page1_block_chanel == null) {
            alert("กรุณาป้อนช่องทางการติดต่อ");
            nextStep(1);
        } else if (val_page1_object == undefined || val_page1_object == null) {
            alert("กรุณาป้อนวัตถุประสงค์การติดต่อ");
            nextStep(1);
        }
        else if (hour == undefined || hour == null) {
            alert("กรุณาป้อนชั่วโมงการติดต่อ");
            nextStep(1);
        } else if (minute == undefined || minute == null) {
            alert("กรุณาป้อนนาทีการติดต่อ");
            nextStep(1);
        }
        else {
            nextStep(2);
        }
    }

</script>

